package com.conversationboard.controller;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.conversationboard.model.User;

@WebServlet(name = "AdminAdviseGCControllerServlet", urlPatterns = "/Admin/AdminAdviseGCControllerServlet")
public class AdminAdviseGCControllerServlet extends HttpServlet {

	private static final long serialVersionUID = -8743822823717818795L;


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		try {
			request.setCharacterEncoding("UTF-8");
			response.setCharacterEncoding("UTF-8");

			User user = User.get(request.getUserPrincipal());

			if (!SecurityChecks.passes(request, user, this)) {
				return;
			}

			System.gc();

			RequestDispatcher dispatcher = request.getRequestDispatcher("/Admin/AdminCacheSizesControllerServlet");
			dispatcher.forward(request, response);

		} catch (SQLException e) {
			throw new ServletException(e);
		}

	}

}
